import 'package:flutter/material.dart';

import '../../config/public_color.dart';
import '../../config/public_text.dart';
import '../bar/public_app_bar.dart';
import 'show_image_view.dart';

/// FileName show_image_page
///
/// @Author lax
/// @Date 2023/3/23
///
/// @Description

class ShowImagePage extends StatefulWidget {
  static String routerName = '/show_image_page';

  /// 本地路径
  final String? localPath;

  /// bundle路径
  final String? bundlePath;

  final String? urlString;

  final double? minScale;

  final double? maxScale;

  final bool? canSave;

  final List<Widget>? actions;

  const ShowImagePage({
    super.key,
    this.localPath,
    this.bundlePath,
    this.urlString,
    this.minScale,
    this.maxScale,
    this.canSave = true,
    this.actions,
  });

  @override
  State<StatefulWidget> createState() {
    return ShowImagePageState();
  }
}

class ShowImagePageState extends State<ShowImagePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: PublicColor.background,
      appBar: PublicAppBar(
        title: PublicText.viewImage,
        actions: widget.actions,
      ),
      body: body(),
    );
  }

  Widget body() {
    return Center(
      child: ShowImageView(
        localPath: widget.localPath,
        bundlePath: widget.bundlePath,
        urlString: widget.urlString,
        minScale: widget.minScale,
        maxScale: widget.maxScale,
        canSave: widget.canSave,
      ),
    );
  }
}
